<template>
  <div class="layout">
      <header v-show="isShowHeader">
          <button v-show="isShowBack" @click="back" class="psBtn">返回</button>
          {{ title }}
      </header>
      <main>
          <slot name="mainTop"></slot>

          <slot name="login"></slot>
      </main>
      <footer v-show="isShowFooter">底部</footer>
  </div>
</template>

<script>
export default {
    props: {
        // 控制是否显示头部
        isShowHeader: {
            type: Boolean,
            default: true
        },
        // 控制是否显示底部
        isShowFooter: {
            type: Boolean,
            default: true
        },
        // 标题
        title: {
            type: String,
            default: "默认标题"
        },
        // 控制是否有返回
        isShowBack: {
            type: Boolean,
            default: true
        },
        // 可以设置返回几页
        goBackNum: {
            type: Number,
            default: 1
        },
    },
    methods: {
        back() {
            console.log('我可以返回'+ this.goBackNum + '页')
        }
    }
}
</script>

<style scoped>
.layout {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.layout > header {
    height: 46px;
    text-align: center;
    line-height: 46px;
}

.layout > main {
    flex: 1;
}

.layout > footer {
    height: 46px;
    text-align: center;
    line-height: 46px;
}

.psBtn {
    position: absolute;
    left: 10px;
    top: 15px;
}
</style>